<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子40-ES6/7常用语法介绍</title>
    </head>

    <body>
        <pre>
            <code>
                // 例子40

                function Point(x, y) {
                    this.x = x;
                    this.y = y;
                }

                Point.prototype.getX = function() {
                    return this.x;
                }

                Point.prototype.getY = function() {
                    return this.y;
                }

                let p = new Point(1, 2);
                console.log(p, p.getX(), p.getY()); // Point {x: 1, y: 2} 1 2

                //--------------------------------------------------------------------------

                class Point {
                    constructor(x, y) {
                        this.x = x;
                        this.y = y;
                    }

                    getX() {
                        return this.x;
                    }

                    getY() {
                        return this.y;
                    }
                }

                let p = new Point(1, 2);
                console.log(p, p.getX(), p.getY()); // Point {x: 1, y: 2} 1 2

            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/40.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>

</html>